import api from './http';
import { ApiResponse } from './index';

/**
 * 行政区划信息
 */
export interface SDTBAreaMappingTreeVo {
  /**
   * 区域编码
   */
  areaCode?: string;
  /**
   * 行政级别
   */
  areaLevel?: number;
  /**
   * 区域名称
   */
  areaName?: string;
  children?: SDTBAreaMappingTreeVo[];
  createTime?: Date;
  createUserAccount?: string;
  id?: number;
  root?: boolean;
  /**
   * 上级编码
   */
  superCode?: string;
  updateTime?: Date;
  updateUserAccount?: string;
}

/**树形结构查询区域 */
export const areaSelectTreeList = (): Promise<ApiResponse<SDTBAreaMappingTreeVo[]>> => {
  return api.doGet('/countygardenApp/SdTbAreaMapping/selectTreeList');
};

export interface ZoningPlanData {
  areaCode: string;
  areaName: string;
  boundary: any;
  fullName: string;
  properties: any;
}

/**查询当前区域行政区划 */
export const getZoningPlan = (superCode: string): Promise<ApiResponse<ZoningPlanData[]>> => {
  return api.doGet('/sdApp/sdTbAdministration/getList?superCode=' + superCode);
};

/**@params 根据点查询区划静态数据 */
export interface AreaGetByMetaParams {
  level?: number;
  wktString: string;
}
/**
 * SdTbAdministration
 */
export interface SDTBAdministration {
  /**
   * 区划代码
   */
  areaCode?: string;
  /**
   * 区划等级
   */
  areaLevel?: number;
  /**
   * 区划名称
   */
  areaName?: string;
  boundary?: any;
  createTime?: Date;
  createUserAccount?: string;
  /**
   * 区划全称
   */
  fullName?: string;
  id?: number;
  /**
   * 区划属性
   */
  properties?: { [key: string]: { [key: string]: any } };
  /**
   * 上级代码
   */
  superCode?: string;
  /**
   * 上级名称
   */
  superName?: string;
  updateTime?: Date;
  updateUserAccount?: string;
}
/**根据点查询区划静态数据 */
export const areaGetByMeta = (
  params: AreaGetByMetaParams
): Promise<ApiResponse<SDTBAdministration>> => {
  return api.doPost('/sdApp/sdTbAdministration/getOne', params);
};
